package com.litong.vertx.hello;

import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServer;

/**
 * Created by litongjava@qq.com on 2020/9/9_22:09
 */
public class ListenHandler implements Handler<AsyncResult<HttpServer>> {

  private Promise<Void> startPromise;
  public ListenHandler(Promise<Void> startPromise){
    this.startPromise=startPromise;
  }
  @Override
  public void handle(AsyncResult<HttpServer> http) {
    if (http.succeeded()) {
      startPromise.complete();
      System.out.println("HTTP server started on port 8888");
    } else {
      startPromise.fail(http.cause());
    }
  }
}
